use std::ops::Add;

struct Solution {}

fn main() {}

impl Solution {
    pub fn to_goat_latin(sentence: String) -> String {
        let words: Vec<&str> = sentence.split_whitespace().collect();
        let mut new_words:Vec<String> = vec![];
        for idx in 0..words.len() {
            let mut new_word: String = Self::change(words[idx]);
            new_word.push_str(&'a'.to_string().repeat(idx + 1));
            new_words.push(new_word);
        }
        new_words.join(" ")
    }

    pub fn change(word: &str) -> String {
        let start_char = word.chars().next().unwrap();
        if "aeiouAEIOU".contains(start_char) {
            return word.to_string() + "ma";
        } else {
            let body = word[1..].to_string();
            let binding = start_char.to_string();
            let x = binding.as_str();
            return body + x + "ma";
        }
    }
}